/*
 * @description: 
 * @Author: Islands
 * @Date: 2024-06-17 16:31:16
 * @LastEditTime: 2024-06-21 13:35:56
 */
import { doHttp } from '@/plugins/axios/index';
import { ILoginData } from '../types/login.d';
import { AES_Encrypt } from '@/utils/aes-crypto/index';


// enum Api {
//     login = "/system/login",
//     token = "/system/getAccessToken",
//     routes= "../../../mock/routes.json",
//     userinfo="../../../mock/userinfo.json"
// }

enum Api {
    login = "../../../mock/accountToken.json",
    token = "../../../mock/accountToken.json",
    routes = "../../../mock/routes.json",
    userinfo = "../../../mock/userinfo.json",
    logout = "../../../mock/logout.json",
    checkLogin = "../../../mock/checkLogin.json"
}

/**
 * 登录请求
 * @param loginData 
 * @returns 
 */
export function doLogin(loginData: ILoginData): any {
    return doHttp('post', Api.login, loginData);
}

/**
 * 获取token
 * @returns 
 */
export function doToken(): any {
    return doHttp('get', Api.token, null);
}


/**
 * 路由查询
 * @returns 
 */
export function doRoutes() {
    return doHttp('get', Api.routes, null);
}

/**
 * 用户信息查询
 * @returns 
 */
export function doUserinfo() {
    return doHttp('get', Api.userinfo, null);
}

/**
 * 用户信息查询
 * @returns 
 */
export function doLogout(): any {
    return doHttp('get', Api.logout, null);
}

/**
 * 验证登录
 * @returns 
 */
export function doCheckLogin(username: string, password: string): any {
    return doHttp('post', Api.checkLogin, { username: username, password: AES_Encrypt(password) });
}

/**
 * 更新密码
 * @returns 
 */
export function doEditPassword(username: string, password: string): any {
    return doHttp('post', Api.checkLogin, { username: username, password: AES_Encrypt(password) });
}